package tasks.OpportunitiesBaseData.MainView;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import core.Functions;

public class ITSLayout extends BrandLayout{
	
	//Attributes for ITS
	private String decDate;
	private String serviceLine;
	private String spl;
	private String totalOppVal;
	private String projectedYield;
	private String coseInd;
	private String sdInd;
	
	public String getDecDate() {
		
		String retVal = "";
		
		String patternFE = "MMM dd yyyy";
		String patternDB = "yyyy-MM-dd";
		
	    SimpleDateFormat format = null;
	    
	    if(this.decDate.contains("-"))
	    {
	    	format = new SimpleDateFormat(patternDB);
	    }
	    else
	    {
	    	format = new SimpleDateFormat(patternFE);
	    }
	    
	    try {
	      Date date = format.parse(this.decDate);
	      retVal = date.toString();
	    } catch (ParseException e) {
	      e.printStackTrace();
	    }
		
		return retVal;
	}
	
	public void setDecDate(String decDate) {
		this.decDate = (decDate != null)?escapeSpecChars(decDate.trim()):"";
	}
	
	public String getServiceLine() {
		return serviceLine;
	}
	
	public void setServiceLine(String serviceLine) {
		this.serviceLine = (serviceLine != null)?escapeSpecChars(serviceLine.trim()):"";
	}
	
	public String getSpl() {
		return spl;
	}
	
	public void setSpl(String spl) {
		this.spl = (spl != null)?escapeSpecChars(spl.trim()):"";;
	}
	
	public String getTotalOppVal() {
		String retVal = "";
		
		retVal = Functions.formatDoubleToString(Double.parseDouble(totalOppVal), 1);
		
		return retVal;
	}
	
	public void setTotalOppVal(String totalOppVal) {
		this.totalOppVal = (totalOppVal != null)?escapeSpecChars(totalOppVal.trim()):"";;
	}
	
	public String getProjectedYield() {
		return projectedYield;
	}
	
	public void setProjectedYield(String projectedYield) {
		this.projectedYield = (projectedYield != null)?escapeSpecChars(projectedYield.trim()):"";;
	}
	
	public String getCoseInd() {
		return coseInd;
	}
	
	public void setCoseInd(String coseInd) {
		this.coseInd = (coseInd != null)?escapeSpecChars(coseInd.trim()):"";;
	}
	
	public String getSdInd() {
		return sdInd;
	}
	
	public void setSdInd(String sdInd) {
		this.sdInd = (sdInd != null)?escapeSpecChars(sdInd.trim()):"";;
	}
	
	public boolean isEqual(ITSLayout layout)
	{
		boolean result = super.isEqual(layout);;
		
		if(!this.getDecDate().equals(layout.getDecDate())) 
		{ 
			result = false;
			setComment("Difference in Dec Date  -   " + this.getDecDate() + " != " + layout.getDecDate()); 
		}
		
		if(!this.getServiceLine().equals(layout.getServiceLine())) 
		{ 
			result = false;
			setComment("Difference in Service Line -   " + this.getServiceLine() + " != " + layout.getServiceLine()); 
		}
		
		if(!this.getSpl().equals(layout.getSpl())) 
		{ 
			result = false;
			setComment("Difference in SPL  -   " + this.getSpl() + " != " + layout.getSpl()); 
		}
		
		if(!this.getTotalOppVal().equals(layout.getTotalOppVal())) 
		{ 
			result = false;
			setComment("Difference in Total Opp Val  -   " + this.getTotalOppVal() + " != " + layout.getTotalOppVal()); 
		}
		
		if(!this.getProjectedYield().equals(layout.getProjectedYield())) 
		{ 
			result = false;
			setComment("Difference in Projected Yield  -   " + this.getProjectedYield() + " != " + layout.getProjectedYield()); 
		}
		
		if(!this.getCoseInd().equals(layout.getCoseInd())) 
		{ 
			result = false;
			setComment("Difference in Cose Ind  -   " + this.getCoseInd() + " != " + layout.getCoseInd()); 
		}
		
		if(!this.getSdInd().equals(layout.getSdInd())) 
		{ 
			result = false;
			setComment("Difference in Sd Ind  -   " + this.getSdInd() + " != " + layout.getSdInd()); 
		}
		return result;
	}
}
